package com.cjh.common.utils;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.DigestUtils;

import java.util.UUID;


public class StringUtil {
    /**
     * 生成随机字符串
     */
    public static String generateUUID(){
        return UUID.randomUUID().toString().replaceAll("-","");
    }

    /**
     * MD5加密
     */
    public static String md5(String key){
        if (StringUtils.isBlank(key)){
            return null;
        }
        return DigestUtils.md5DigestAsHex(key.getBytes());
    }

    public static Integer changeString(String string){
        if (string != null && !StringUtils.isBlank(string)) {
            return Integer.valueOf(string);
        }else {
            return null;
        }
    }


    public static void main(String[] args) {

        //加密
        String uuid = generateUUID();

        System.out.println(uuid);
        String password =  md5("123456"+"f41cba1f7dd04793822b32da8b009058");
        System.out.println(password);

//        this.equals(StringUtil.md5(inPassword + slat), dbPassword)
    }
}
